import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// ignore: import_of_legacy_library_into_null_safe
import "package:get/get.dart";
// ignore: unused_import
import 'package:getx/utils/getx.dart';
import 'package:getx/model/messages.dart';

void main() {
  runApp(
    GetMaterialApp(
      debugShowCheckedModeBanner: false,
      home: const MyApp(),
      translations: Messages(),
      locale: const Locale('zh', 'CN'),
      fallbackLocale: const Locale('zh', 'CN'),
    ),
  );
   
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  // ignore: non_constant_identifier_names
  final List GetxLists = GetxUtils.GetxLists;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('flutter开发'),
      ),
      body: Column(
        children: [
          Expanded(
            child: ListView(
              children: GetxLists.map(
                (e) {
                  final int index = GetxLists.indexOf(e) + 1;
                  return ListTile(
                    leading: CircleAvatar(
                      backgroundColor: Theme.of(context).primaryColor,
                      child: Text(index.toString()),
                      foregroundColor: Colors.white,
                    ),
                    title: Text(e['text']),
                    onTap: () {
                      Navigator.of(context).push(
                        MaterialPageRoute(
                          builder: (context) {
                            return e['content']; //返回的是需要跳转单页面
                          },
                        ),
                      );
                    },
                  );
                },
              ).toList(),
            ),
          ),
        ],
        mainAxisAlignment: MainAxisAlignment.center,
      ),
    );
  }
}
